<template>
  <div class="search">
    <a-modal v-model="modalVisible" :title="modalTitle" width="650px" @ok="handleSubmit">
      <f-form ref="form" :action="api.dict" :form-key="this.formItem.dictId" @success="onSuccess">
        <f-form-item label="分类名称" name="dicTitle" :required="true" :value="formItem.dicTitle"/>
        <f-form-item label="分类编码" name="dicType" :required="true" :value="formItem.dicType"/>
      </f-form>
    </a-modal>
  </div>
</template>

<script>
  export default {
    name: 'dictForm',
    props: {},
    data () {
      return {
        modalVisible: false,
        load: false,
        title: '添加分类',
        formItem: this.getFormItem()
      }
    },
    methods: {
      handleShow (data) {
        this.formItem = this.getFormItem()
        if (data && data.dictId) {
          this.formItem = data
        }
        this.modalVisible = true
      },
      getFormItem () {
        return {}
      },
      onSuccess () {
        this.modalVisible = false
        this.$emit('success')
      },
      handleSubmit () {
        this.$refs.form.submit()
      }
    },
    computed: {
      modalTitle: function () {
        return this.title
      }
    },
    created () {

    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
